package edu.zut.cs.network.Experiment2;
import javax.swing.JOptionPane;
public class Test4 {
    public static void main(String[] args) {
        String let=JOptionPane.showInputDialog("请输入一个三位数：");

        int num = Integer.parseInt(let);
        if(num>0 && num<1000) {
//        System.out.println(num);
            int firstNum = num / 100;
            int secondNum = num / 10 % 10;
            int thirdNum = num % 10;
            int sum = firstNum + secondNum + thirdNum;
//        System.out.println(sum);
            JOptionPane.showMessageDialog(null, "各个数字之和：" + sum,
                    "结果", JOptionPane.INFORMATION_MESSAGE);
        }
        else{
            JOptionPane.showMessageDialog(null,"输入数字有误",
                    "提示",JOptionPane.INFORMATION_MESSAGE);
        }
    }
}
